<template>
  <uni-popup ref="popup" class="distance-top100 left70" type="message" :mask-click="false">
    <uni-popup-message type="success" :message="'区块Hash为：'+hash" :duration="0"/>
    <uni-popup-message type="success" :message="'上链时间为：'+time" :duration="0"/>
    <uni-popup-message type="success" :message="'事件描述：'+describe" :duration="0"/>
    <uni-popup-message type="success" :message="'事件ID：'+id" :duration="0"/>
    <uni-popup-message type="success" :message="key" :duration="0" v-for="key of data" :key="key"/>
  </uni-popup>
</template>

<script lang="ts">
import UniPopup from '@dcloudio/uni-ui/lib/uni-popup/uni-popup.vue';
import UniPopupMessage from "@dcloudio/uni-ui/lib/uni-popup-message/uni-popup-message.vue";

function createHash() {
  return Array.from(Array(Number() || 16), () => Math.floor(Math.random() * 36).toString(36)).join('');
}

export default {
  name: "blockChain",
  components: {
    UniPopup, UniPopupMessage
  },
  methods: {
    open() {
      this.hash = createHash()
      this.id = createHash()
      this.time = new Date().toLocaleString()
      this.$refs.popup.open("top")
    },
    close() {
      this.$refs.popup.close()
    }
  },
  data() {
    return {
      hash: "",
      id: "",
      time: ""
    }
  },
  props: {
    describe: {
      type: String,
      default: ""
    },
    data: {
      type: Array,
      default: []
    }
  }
}

</script>
